import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	topListIds:[],
    nextId: "",
	bgAudio:null
  },
  mutations: {
    INIT_TOPLISTIDS (state, payload) {
      state.topListIds = payload;
    },
	NEXT_ID(state, payload){
		if(state.topListIds.length < 2){
			state.nextId = payload
			
		}
		else if(payload == state.topListIds[state.topListIds.length - 1].id){
			state.nextId = state.topListIds[state.topListIds.length - 1].id 
		}
		else{
			for(var i=0;i<state.topListIds.length - 1;i++){
				if(state.topListIds[i].id == payload){
					state.nextId = state.topListIds[i+1].id 
				}
		}
			
		}
	},
	BG_AUDIO(state, payload) {
	  state.bgAudio = payload;
	},
	
	
  }
})